package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.domain.db.Freeze;
import com.tanhua.dubbo.api.db.FreezeApi;
import com.tanhua.dubbo.mapper.FreezeMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class FreezeApiImpl implements FreezeApi {


    @Autowired
    private FreezeMapper freezeMapper;


    @Override
    public void save(Freeze freeze) {
        freezeMapper.insert(freeze);
    }

    @Override
    public Freeze findById(Long userId) {


        QueryWrapper<Freeze> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(Freeze::getUserId, userId);
        return freezeMapper.selectOne(queryWrapper);
    }

    @Override
    public void findByIddelete(Long userId) {
        QueryWrapper<Freeze> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(Freeze::getUserId, userId);
        freezeMapper.delete(queryWrapper);
    }
}
